package com.bydq.patrolsystem.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bydq.patrolsystem.entity.*;
import com.bydq.patrolsystem.service.PsLineInfoService;
import com.bydq.patrolsystem.service.PsPoleInfoService;
import com.bydq.patrolsystem.service.PsSolvetaskMainService;
import com.bydq.patrolsystem.service.PsSystemconfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/solver")
public class SolvetaskController {

    @Autowired
    private PsSolvetaskMainService psSolvetaskMainService;

    @Autowired
    private PsSystemconfigService psSystemconfigService;


    /**
     * 页面跳转至消缺任务指定与分配页面solveTask.xml
     * @return
     */
    @RequestMapping("/solveTask")
    public String solveTask( ){
            return "solveTask";
    }

    /**
     * 消缺任务列表页
     * @param
     * @return
     */
    @ResponseBody
    @RequestMapping("/solveList")
    public Map<String,Object> poleList(String solveTaskCode,String solveTaskName, Long taskStatus,
                                       String issuedByName, String startDate,String endDate,
                                       Integer page, Integer limit) {
        System.out.println("solveTaskCode:"+solveTaskCode);
//        System.out.println("lineCode:"+lineCode);
//        System.out.println("poleCode:"+poleCode);
//        System.out.println("discovererName:"+discovererName);
        IPage<PsSolvetaskMain> pages = psSolvetaskMainService.selectSolvetaskListByPaging(solveTaskCode,solveTaskName, taskStatus,
                issuedByName, startDate,endDate,
                page, limit);
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("code", 0);
        map.put("msg", "");
        map.put("count", pages.getTotal());
        map.put("data", pages.getRecords());
//        System.out.println(map.toString());
        return map;
    }

    /**
     * 查询任务状态下拉列表集合
     * @param
     * @return
     */
    @ResponseBody
    @RequestMapping("/taskStatusList")
    public List<PsSystemconfig> taskStatusList(){
        String configCode = "TASK_STATUS";
        QueryWrapper<PsSystemconfig> qw=new QueryWrapper<>();
        qw.eq("configCode",configCode);
//        System.out.println(psSystemconfigService.list(qw));
        return psSystemconfigService.list(qw);
    }






}
